﻿Public Class EnviarCorreo 

    Private Sub SimpleButton2_Click(sender As System.Object, e As System.EventArgs) Handles SimpleButton2.Click
        Timer1.Enabled = False
        Me.Close()
    End Sub

    Private Sub SimpleButton1_Click(sender As System.Object, e As System.EventArgs) Handles SimpleButton1.Click
        If ServicioCorreoSGS.HayConexionInternet = False Then
            MsgBox("No se encontró conexión a Internet", MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "Error en la conexión")
        Else
            If asunto.Text.Length = 0 Then
                ErrorProvider1.SetError(asunto, "Debe ingresar el asunto del mensaje")
                Return
            End If
            ErrorProvider1.SetError(asunto, Nothing)
            If mensaje.Text.Length = 0 Then
                ErrorProvider1.SetError(mensaje, "Debe ingresar el Asuntocuerpo del mensaje")
                Return
            End If
            ErrorProvider1.SetError(mensaje, Nothing)
            ServicioCorreoSGS.EnviarCorreo(asunto.Text, mensaje.Text)
            asunto.Text = ""
            mensaje.Text = ""
            asunto.Focus()
        End If
    End Sub

    Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
        If ServicioCorreoSGS.HayConexionInternet Then
            lbhayconexion.Visible = True
            pichayconexion.Visible = True
            lbnohayconexion.Visible = False
            picnohayconexion.Visible = False
        Else
            lbhayconexion.Visible = False
            pichayconexion.Visible = False
            lbnohayconexion.Visible = True
            picnohayconexion.Visible = True

        End If
    End Sub

    Private Sub EnviarCorreo_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        Timer1.Enabled = False
    End Sub

    Private Sub EnviarCorreo_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        ErrorProvider1.SetError(mensaje, Nothing)
        ErrorProvider1.SetError(asunto, Nothing)
        asunto.Focus()
    End Sub
End Class